

package com.hazelcast.partition;

import com.hazelcast.cluster.Member;

/**
 * An event fired when a partition replica migration completes or fails.
 *
 * @see Partition
 * @see PartitionService
 * @see MigrationListener
 */
public interface ReplicaMigrationEvent extends PartitionEvent {

    /**
     * Returns the index of the partition replica.
     * 0th index is primary replica, 1st index is 1st backup and so on.
     *
     * @return the index of the partition replica
     */
    int getReplicaIndex();

    /**
     * Returns the old owner of the migrating partition replica.
     *
     * @return the old owner of the migrating partition replica
     */
    Member getSource();

    /**
     * Returns the new owner of the migrating partition replica.
     *
     * @return the new owner of the migrating partition replica
     */
    Member getDestination();

    /**
     * Returns the result of the migration: completed or failed.
     *
     * @return true if the migration completed successfully, false otherwise
     */
    boolean isSuccess();

    /**
     * Returns the elapsed the time of this migration in milliseconds.
     *
     * @return elapsed time in milliseconds.
     */
    long getElapsedTime();

    /**
     * Returns the progress information of the overall migration.
     *
     * @return migration process progress
     */
    MigrationState getMigrationState();
}
